package com.ita.controller;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import com.ita.pojo.Customer;
import com.ita.service.CustomerManger;

@RestController
@RequestMapping(value = "/customers")
public class CustomerController {

	@Resource(name="cusManager")
	private CustomerManger manger;

	@RequestMapping(value = "/add", method = RequestMethod.POST, consumes = "application/json")
	public Customer addCustomer(@RequestBody Customer c) {

		
		return manger.addCustomer(c);
	}

	@RequestMapping(value = "/update", method = RequestMethod.PUT, consumes = "application/json")
	public Customer updateCustomer(@RequestBody Customer c) {

		return manger.updateCustomer(c);
	}

	@RequestMapping(value = "/listAll", method = RequestMethod.GET)
	public List<Customer> findAllCustomer() {

		return manger.findAllCustomers();
	}

	@RequestMapping(value = "/delete", method = RequestMethod.DELETE)
	public String deleteCustomer(String id) {

		return manger.deleteCustomer(id);
	}
}
